﻿@{
    Layout = "_LayoutPhone";
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>
<script src="~/rolldate.min.js"></script>
<header style="width: 100%; height: 4rem; background-color: rgb(255,135,0);top:0px;position: fixed;z-index: 1;">
    <a href="javascript:void(window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww500458ad942a211f&redirect_uri=http://web.xyufu.cn/PhoneShouYe/ShouYe&response_type=code&scope=snsapi_privateinfo&agentid=1000002&state=STATE#wechat_redirect')" id="a">
        <img src="~/GoTRI/img/left.png" alt="" style="float: left;
            width: 1rem;
            height: 2rem;
            margin-left: 1rem;
            margin-top: 1rem;
            position:absolute;
	        left:0px;
	        top:0px;
	        z-index:1;">
    </a>
    <div style=" width: 100%; height: 4rem; line-height: 4rem; text-align: center; color: #fff; font-size: 1.3rem;">备忘录</div>
</header>
<div style="width:1px;padding-bottom:50px"></div>
<script>
    $(".yi").attr("hidden", "");
</script>
<div class="container mt-4 main-container">
    <div class="card mb-4">
        <div class="main" style="padding:0px;margin:0px;width:100%">
            <div class="tab-content">
                <div id="new_cust" class="tab-pane active">
                    <div class="card-body">
                        <div class="row justify-content-center">
                            <div class="col-md-10 mx-auto">
                                <div class="form-group row">
                                    <div class="col-lg-6 col-md-6">
                                        <label>备忘录标题</label>
                                        <input id="IptBiaoTi" type="text" name="name" class="form-control" value="" />
                                    </div>
                                    <div class="col-lg-6 col-md-6">
                                        <label>提醒时间</label>
                                        <input readonly class="form-control" type="text" id="date-group1-4" placeholder="YYYY/MM/DD hh:mm">
                                    </div>
                                    <div class="col-lg-6 col-md-6">
                                        <label>内容</label>
                                        <textarea id="IptNeiRong" rows="12" class="form-control"></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="card-footer" style="text-align: center;width:100%">
                        <button class="btn btn-success float-right" id="tijiao" onclick="Add()" style="width:100%; margin-bottom:70px;">提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div style="margin-bottom: 50px;padding-bottom:1px"></div>
<script>
    $(document).ready(function () {
        if (getQuery("Id") != null) {
            $("#tijiao").hide();
            Bind();
            $('#a').removeAttr("href");
            $('#a').attr('href', "List");
        } else {
            $('#a').removeAttr("href");
            $('#a').attr('href', "javascript:void(window.location.href='https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww500458ad942a211f&redirect_uri=http://web.xyufu.cn/PhoneShouYe/ShouYe&response_type=code&scope=snsapi_privateinfo&agentid=1000002&state=STATE#wechat_redirect')");
        }
        new Rolldate({
            el: '#date-group1-4',
            format: 'YYYY/MM/DD hh:mm:ss',
            beginYear: 2000,
            endYear: 2100
        })
        $('#SelYear').bind('input propertychange', function () {
            $("#SelDay").empty();
            BindSelDay($("#SelYear").val(), $("#SelMonth").val());
        })
        $('#SelMonth').bind('input propertychange', function () {
            $("#SelDay").empty();
            BindSelDay($("#SelYear").val(), $("#SelMonth").val());
        })
    });
    function getDaysInMonth(year, month) {
        //debugger;
        month = parseInt(month, 10);
        var temp = new Date(year, month, 0);
        return temp.getDate();
    }
    function BindSelDay(year, month) {
        var ddl = $("#SelDay");
        for (var i = 0; i < getDaysInMonth(year, month); i++) {
            var opt = $("<option></option>").text((i + 1)).val((i + 1));
            ddl.append(opt);
        }
    }
    function Bind() {
        $.ajax({
            url: "../PhoneBeiWangLu/GetById",
            data: { "Id": getQuery("Id") },
            type: "post",
            dataType: "json",
            success: function (response) {
                console.log(response);
                $(response).each(function (key) {
                    $('#IptBiaoTi').val(response[key].BiaoTi);
                    $('#date-group1-4').val(response[key].TiXingShiJian);
                    $('#IptNeiRong').val(response[key].NeiRong);
                })
            }
        });
    }
    function Add() {
        $.ajax({
            url: "../PhoneBeiWangLu/Add",
            data: { "NeiRong": $("#IptNeiRong").val(), "BiaoTi": $("#IptBiaoTi").val(), "Time": $("#date-group1-4").val() },
            type: "post",
            dataType: "text",
            success: function (response) {
                if (response == "success") {
                    location.href = "../PhoneBeiWangLu/List";
                }
            }
        });
    }
    function getQuery(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]); return null;
    }
</script>